package top.marken.onlineclass.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.marken.onlineclass.model.entity.Video;
import top.marken.onlineclass.model.entity.VideoBanner;
import top.marken.onlineclass.service.VideoService;
import top.marken.onlineclass.util.JsonData;

import java.util.List;

/**
 * 录像业务接口
 */
@RestController
@RequestMapping("/api/v1/pub/video")
public class VideoController {
    @Autowired
    private VideoService videoService;

    /**
     * 录像列表
     */
    @RequestMapping("/list")
    public JsonData list() {
        List<Video> videos = videoService.listVideo();
        return JsonData.buildSuccess(videos);
    }

    /**
     * 录像轮播图列表
     * @return
     */
    @RequestMapping("/banner_list")
    public JsonData bannerList() {
        List<VideoBanner> videoBanners = videoService.listVideoBanner();
        return JsonData.buildSuccess(videoBanners);
    }

    /**
     * 通过视频Id查询此视频的详情信息
     * @param videoId
     * @return
     */
    @GetMapping("/detail")
    public JsonData getDetailById(@RequestParam(name = "video_id", required = true) int videoId) {
        Video video = videoService.findDetailById(videoId);
        return JsonData.buildSuccess(video);
    }
}
